package com.example.md.mddemo.java8.stream;

import java.util.ArrayList;
import java.util.List;

/**
 * Copyright © 2018年 mddemo. All rights reserved.
 *
 * @author 临江仙 hzqiuxm@163.com
 * 水果生成选择类
 * @date 2018/12/1 11:02
 * @Since 1.0.0
 */
public abstract class FruitSelector {

    //等待筛选的水果类型
    protected final static String CANDIDATE_FRUIT = "apple";

    private List<Fruit> getFruit(){

        final List<Fruit> fruits = new ArrayList<Fruit>(){

            {
                add(new Fruit("apple",22.1));
                add(new Fruit("apple",22.2));
                add(new Fruit("apple",22.3));
                add(new Fruit("apple",22.4));
                add(new Fruit("apple",22.5));
                add(new Fruit("apple",22.6));
                add(new Fruit("apple",22.7));
                add(new Fruit("orange",22.8));
                add(new Fruit("orange",22.9));
                add(new Fruit("orange",23.0));
                add(new Fruit("orange",23.1));
                add(new Fruit("orange",24.2));
                add(new Fruit("orange",22.3));
                add(new Fruit("banana",22.4));
                add(new Fruit("banana",22.2));
                add(new Fruit("banana",22.2));
                add(new Fruit("banana",22.2));
                add(new Fruit("banana",22.2));
            }

         };

        return fruits;
    }


    public List<Double> select()
    {
        List<Fruit> fruits= getFruit();
        return doFilter(fruits);
    }

    protected abstract List<Double> doFilter(final List<Fruit> fruits);
}
